using UnityEngine;
using UnityEngine.UI;

namespace NewRedDotSystem
{
    public class RedDotTester : MonoBehaviour
    {
        [SerializeField] private InputField m_redDotIdField;
        [SerializeField] private InputField m_countField;
        [SerializeField] private Button m_updateBtn;

        private void Awake()
        {
            m_updateBtn.onClick.AddListener(OnUpdateBtnClick);
        }

        private void OnUpdateBtnClick()
        {
            if (!string.IsNullOrEmpty(m_redDotIdField.text) && !string.IsNullOrEmpty(m_countField.text))
            {
                ChangeRedNoteState(m_redDotIdField.text, m_countField.text);
            }
        }

        private void ChangeRedNoteState(string key, string count)
        {
            if (int.TryParse(key, out int intKey) && int.TryParse(count, out int intCount))
            {
                RedDotSystem.Instance.UpdateRedDotCount((uint)intKey, intCount);
            }
        }
    }
}
